package bigdata.backend.datasource.service;

import com.baomidou.mybatisplus.extension.service.IService;
import bigdata.backend.datasource.entity.Datasource;

import javax.sql.DataSource;
import java.util.List;
import java.util.Map;


public interface DatasourceService extends IService<Datasource> {
    DataSource registerDataSource(Datasource ds);

    void unregisterDataSource(String alias);

    List<String> getAllTables(Datasource ds);

    List<Map<String, Object>> getTableColumns(Datasource ds, String tableName);

    String getCreateTableSql(Datasource ds, String tableName);

    String getTableComment(Datasource ds, String tableName);

    List<Map<String, Object>> executeQuery(Datasource ds, String sql);
    List<Map<String, Object>> executeQuery(Datasource ds, String sql, Object... params);

    int executeUpdate(Datasource ds, String sql);
    int executeUpdate(Datasource ds, String sql, Object... params);

    void executeDdl(Datasource ds, String sql);
    void executeDdl(Datasource ds, String sql, Object... params);
    // 校验数据源连通性
    boolean testConnection(Datasource ds);
    boolean testConnectionById(String id);

    boolean updateByIdIncludingNulls(Datasource datasource);
}
